package com.jcark.mvvm.Interceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * @author ShineYang
 * @date 2020/9/14
 * description:
 */
public class HttpResponseInterceptor implements Interceptor {
    private static final int UNAUTHORIZED = 401;
    private static final int FORBIDDEN = 403;
    private static final int NOT_FOUND = 404;
    private static final int NOT_ALLOWED = 405;
    private static final int REQUEST_TIMEOUT = 408;
    private static final int INTERNAL_SERVER_ERROR = 500;
    private static final int BAD_GATEWAY = 502;
    private static final int SERVICE_UNAVAILABLE = 503;
    private static final int GATEWAY_TIMEOUT = 504;

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());
        if (response.code() == BAD_GATEWAY) {
            jumpToServiceUnavailablePage();
        }
        return response;
    }

    //设置维护页h5
    private void jumpToServiceUnavailablePage() {
      /*  MyApplication.getAppInstance().finishAllActivities();
        switch (BuildConfig.FLAVOR) {
            case "product":
                BaseWebActivity.launch("https://mmh5.qianyi.ltd/systemUpdate", "服务维护中", false);
                break;
            default:
                BaseWebActivity.launch("https://uath5.qianyi.ltd/systemUpdate", "服务维护中", false);
        }*/
    }
}
